Skip to content

Conversation

@minggangw
Copy link
Member

@minggangw minggangw commented Jun 16, 2025

This PR adds support for setting the domain id for the Context, ensuring that the domain id is handled and returned as a BigInt throughout the API. Key changes include:

  • Adjusting type assertions in tests to expect BigInt for domain ids.
  • Updating the C++ bindings to accept an optional BigInt argument and return a BigInt.
  • Modifying the Context API and initialization code in JavaScript to handle the new domain id.

Fix: #1163

@minggangw minggangw requested a review from Copilot June 16, 2025 05:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for setting the domain id for the Context, ensuring that the domain id is handled and returned as a BigInt throughout the API. Key changes include:

  • Adjusting type assertions in tests to expect BigInt for domain ids.
  • Updating the C++ bindings to accept an optional BigInt argument and return a BigInt.
  • Modifying the Context API and initialization code in JavaScript to handle the new domain id.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/types/index.test-d.ts Updated tests to verify the new BigInt type for domain id.
test/test-context.js Modified tests to reflect the updated domain id expectations.
src/rcl_context_bindings.cpp Changed bindings to accept and return BigInt; added scope_exit for cleanup.
lib/context.js Updated the Context constructor and getter to use domain id as BigInt.
index.js Passed the domain id from the Context instance to the initialization API.
Comments suppressed due to low confidence (1)

lib/context.js:68

  • [nitpick] Consider providing a default value (e.g., 0n) for the domainId parameter in the Context constructor to ensure that this._domainId is always a BigInt, which will clarify the API contract for users.
constructor(domainId) {

size_t domain_id = RCL_DEFAULT_DOMAIN_ID;
if (info.Length() > 2 && info[2].IsBigInt()) {
bool lossless;
domain_id = info[2].As<Napi::BigInt>().Uint64Value(&lossless);
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider checking if the BigInt conversion was lossless by verifying the 'lossless' boolean value; if the conversion is not lossless, it may be appropriate to throw an error to prevent potential data truncation.

Suggested change
domain_id = info[2].As<Napi::BigInt>().Uint64Value(&lossless);
domain_id = info[2].As<Napi::BigInt>().Uint64Value(&lossless);
if (!lossless) {
Napi::Error::New(env, "BigInt conversion to domain_id was not lossless")
.ThrowAsJavaScriptException();
return env.Undefined();
}

Copilot uses AI. Check for mistakes.
@coveralls
Copy link

Coverage Status

coverage: 84.716% (+0.005%) from 84.711%
when pulling 9b10069 on minggangw:fix-1163
into 4cff06a on RobotWebTools:develop.

@minggangw minggangw merged commit 42785df into RobotWebTools:develop Jun 16, 2025
27 of 28 checks passed
minggangw added a commit that referenced this pull request Jun 18, 2025
This PR adds support for setting the domain id for the Context, ensuring that the domain id is handled and returned as a BigInt throughout the API. Key changes include:
- Adjusting type assertions in tests to expect BigInt for domain ids.
- Updating the C++ bindings to accept an optional BigInt argument and return a BigInt.
- Modifying the Context API and initialization code in JavaScript to handle the new domain id.

Fix: #1163
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support setting domain id for Context

2 participants